package com.leetcode.August;

/**
 * @Description: 560. 和为 K 的子数组
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-19 20:50
 */
public class LC560和为K的子数组 {
    public int subarraySum(int[] nums, int k) {
        int res=0;
        int len=nums.length;
        for (int i = 0; i < len; i++) {
            int sum=0;
            for (int j = i; j < len; j++) {
                sum+=nums[j];
                if(sum==k){
                    res++;
                }
            }
        }
        return res;
    }
}
